<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  var arr = [2, 8, 4, 5];
  var obj = { a: 1, b: 2 };

  // 数组和对象转字符串
  console.log(String(arr));   // "2,8,4,5"   可以理解为 arr.join(",")  
  console.log(arr + "");

  console.log(String(obj));  // "[object Object]"    // object => 对象数据  Object=>创建对象的构造函数
  console.log(obj + "");

  // 数组和对象参与运算   
  // 参与 + 运算 先转字符串在拼接
  console.log(arr + 1);
  console.log(obj + 1);

  // 参与 * / % 运算,先转字符串  在参与运算(字符串遇到减乘除 =>转数字,在运算)  => NaN
  console.log(arr * 1);
  console.log(obj * 1);

  // 数组和对象转布尔值   => true
  console.log(Boolean([]));
  console.log(Boolean({}));



</script>

</html>